<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
</head>
<body>
    <div id="app">
        <router-link to="/goods">go to商品页面</router-link>
        <router-link to="/user">go to用户界面</router-link>
        <router-view></router-view>
    </div>
</body>
    <script>
        const Goods = {
            template:`<div>商品页面</div>`
        }
        const User = {
            template:`<div>用户页面</div>`
        }
        const NotFound = {
            template:`<div>页面不存在</div>`
        }
        const routes = [
            
            {
                path:"/goods",
                component:Goods
            },
            {
                path:"/user",
                component:User
            },
            // *匹配一般放最后，越前面优先级越高
            {
                path:"*",
                component:NotFound
            },
        ];
        const router = new VueRouter({
            routes,
        })
        const app = new Vue({
            el:"#app",
            router
        })
    </script>
</html>